package com.douqu.game.auth.web.request;

import com.douqu.game.core.e.E_CdkCodeType;
import com.douqu.game.core.util.StringUtils;

import java.util.Date;

/**
 * @Author: wangzhenfei
 * @Description:
 * @Date: 2017-11-13 15:00
 */
public class AddCdkCodeReqDto {
    private String channel;
    private String project;
    private Integer type;
    private Integer group;
    private Integer times;
    private String reward;
    private Date startTime;
    private Date endTime;
    private Integer count;
    private String remark;



    public String getChannel() {
        return channel;
    }

    public void setChannel(String channel) {
        this.channel = channel;
    }

    public String getProject() {
        return project;
    }

    public void setProject(String project) {
        this.project = project;
    }

    public Integer getType() {
        return type = type == null ? 0 : type.intValue();
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getGroup() {
        return group;
    }

    public void setGroup(Integer group) {
        this.group = group;
    }

    public Integer getTimes() {
        return times == null ? 0 : times.intValue();
    }

    public void setTimes(Integer times) {
        this.times = times;
    }


    public String getReward() {
        return reward;
    }

    public void setReward(String reward) {
        this.reward = reward;
    }

    public Date getStartTime() {
        return startTime;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public Date getEndTime() {
        return endTime;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public Integer getCount() {
        return count = count == null ? 0 : count.intValue();
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public boolean checkParam(){
        if(StringUtils.isNullOrEmpty(channel)){
            return false;
        }

        if(StringUtils.isNullOrEmpty(reward)){
            return false;
        }

        if(StringUtils.isNullOrEmpty(project)){
            return false;
        }

        if(E_CdkCodeType.GROUP_ONCE_USE.getCode() != getType() &&
                E_CdkCodeType.SINGLE_REPEAT_USE.getCode() != getType()){
            return false;
        }

        if(startTime == null || endTime == null || startTime.getTime() >= endTime.getTime() ||
                endTime.getTime() < System.currentTimeMillis()){
            return false;
        }
        if(getCount() <= 0){
            return false;
        }


        return true;
    }

    @Override
    public String toString() {
        return "AddCdkCodeReqDto{" +
                "channel='" + channel + '\'' +
                ", project='" + project + '\'' +
                ", type=" + type +
                ", group=" + group +
                ", times=" + times +
                ", reward='" + reward + '\'' +
                ", startTime=" + startTime +
                ", endTime=" + endTime +
                ", count=" + count +
                ", remark='" + remark + '\'' +
                '}';
    }
}
